package com.inossem.warehousemanage_tv.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.inossem.warehousemanage_tv.R;
import com.inossem.warehousemanage_tv.bean.MainBean;

import java.util.List;

/**
 * 仓库概览-首页
 *
 * @author 詹建宇
 * @time on 2019/2/13 16:51
 * @email jianyu.zhan@inossem.com
 */
public class MainAdapter extends BaseAdapter {

    private Context context;
    private List<MainBean.LocationListBean> list;

    public MainAdapter(Context context, List<MainBean.LocationListBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.view_ware_main_item,null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.locationNameTv.setText(list.get(position).getLocation_name());
        return convertView;
    }

    private class ViewHolder{
        private TextView locationNameTv;

        public ViewHolder(View view) {
            locationNameTv = view.findViewById(R.id.locationNameTv);
        }
    }
}
